﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using anael.Model;

namespace anael.ClientUtilities
{
    public static class Parser
    {
        public static User ParseUser(System.Json.JsonObject jsonObject)
        {
            User user = new User();
            if (jsonObject.ContainsKey("id"))
            {
                user.Id = jsonObject["id"];
            }
            if (jsonObject.ContainsKey("email"))
            {
                user.Email = jsonObject["email"];
            }
            if (jsonObject.ContainsKey("firstName"))
            {
                user.FirstName = jsonObject["firstName"];
            }
            if (jsonObject.ContainsKey("lastName"))
            {
                user.LastName = jsonObject["lastName"];
            }
            if (jsonObject.ContainsKey("gender"))
            {
                user.Gender = jsonObject["gender"];
            }
            if (jsonObject.ContainsKey("link"))
            {
                user.Link = jsonObject["link"];
            }
            if (jsonObject.ContainsKey("name"))
            {
                user.Name = jsonObject["name"];
            }
            if (jsonObject.ContainsKey("updatedTime"))
            {
                user.UpdatedTime = jsonObject["updatedTime"];
            }
            if (jsonObject.ContainsKey("verified"))
            {
                user.Verified = Convert.ToBoolean(jsonObject["verified"].ToString());
            }

            return user;
        }

        public static Friend ParseFriend(System.Json.JsonObject jsonObject)
        {
            Friend friend = new Friend();
            if (jsonObject.ContainsKey("id"))
            {
                friend.Id = jsonObject["id"];
            }

            if (jsonObject.ContainsKey("name"))
            {
                friend.Name = jsonObject["name"];
            }

            if (jsonObject.ContainsKey("firstName"))
            {
                friend.FirstName = jsonObject["firstName"];
            }

            if (jsonObject.ContainsKey("lastName"))
            {
                friend.LastName = jsonObject["lastName"];
            }
            return friend;
        }
    }

}
